import React, {PureComponent} from 'react';
import {Card} from 'antd';
import routes from './routes';
import PropTypes from 'prop-types';
import QueryPanel from './QueryPanel';
import TablePanel from './TablePanel';
import {reportFormList} from '../Enum';
import TableAmount from './TableAmount';
import TableReject from './TableReject';
import TableApprove from './TableApprove';
import {Route, Switch} from 'react-router-dom';
import TableOnePassRate from './TableOnePassRate';
import NoMatchRoute from '../common/NoMatchRoute';
import Breadcrumb from 'Shell/components/Breadcrumb';
// eslint-disable-next-line react/prefer-stateless-function
class App extends PureComponent {
    componentDidMount() {
        this.props.init();
    }
    render() {
        const {conditions} = this.props;
        return (
            <div>
                <Route render={props => <Breadcrumb location={props.location}/>}/>
                <div className="page-main">
                    <Switch>
                        <Route path={routes.query.url()} exact render={() =>
                            <div>
                                <Card>
                                    <QueryPanel />
                                </Card>
                                {conditions.reportForm === reportFormList.索赔单据报表 && <TablePanel/>}
                                {conditions.reportForm === reportFormList.单据审核报表 && <TableApprove/>}
                                {conditions.reportForm === reportFormList.索赔单据量 && <TableAmount/>}
                                {(conditions.reportForm === reportFormList.一次通过率 || conditions.reportForm === reportFormList.通过率) &&
                                    <TableOnePassRate/>}
                                {(conditions.reportForm === reportFormList.拒绝 || conditions.reportForm === reportFormList.退回) &&
                                    <TableReject/>}
                            </div>}/>
                        <NoMatchRoute link={routes.query.url()} />
                    </Switch>
                    
                </div>
            </div>
        );
    }
}

App.propTypes = {
    conditions: PropTypes.object.isRequired,
    init: PropTypes.func,
    queryInitDate: PropTypes.func,
};
import {getInitData} from './actions.js';
import selectorFactory from 'Shared/utils/immutableToJsSelectorFactory';
const getConditions = selectorFactory(['page', 'appState', 'queryCondition']);
import {connect} from 'react-redux';
const mapStateToProps = state => ({
    conditions: getConditions(state)
});
const mapDispatchToProps = dispatch => ({
    init: () => dispatch(getInitData()),
});

export default connect(mapStateToProps, mapDispatchToProps)(App);
